<template>
	<view class="form-select">
		<uni-popup ref="popup">
			<view class="select-body">
				<view class="title">{{ title }}</view>
				<scroll-view class="select-box" scroll-y>
					<radio-group @change="radioChange">
						<label class="uni-list-cell uni-list-cell-pd select-item" v-for="(item, index) in items" :key="item.value">
							<view>
								<radio color="#00a0e9" :value="item.value" :checked="value === item.value" />
							</view>
							<view>{{item.value}}</view>
						</label>
					</radio-group>
				</scroll-view>
			</view>
		</uni-popup>
		<slot></slot>
	</view>
</template>

<script>
	import UniPopup from "../uni_modules/uni-popup/components/uni-popup/uni-popup";

	export default {
		name: "form-select",
		components: {
			UniPopup
		},
		data() {
			return {
				showSelect: false,
			};
		},
		props: ['title', 'items', 'value'],
		methods: {
			radioChange(val) {
				this.$emit('change', val)
				this.close()
			},
			open() {
				this.$refs.popup.open()
			},
			close() {
				this.$refs.popup.close()
			}
		},
	}
</script>

<style lang="less">
	.form-select {
    display: flex;
    width: 100%;
    height: 100%;
		.select-body {
			background: #FFF;
			width: 90vw;

			.title {
				text-align: center;
				font-weight: 600;
				font-size: 36rpx;
				padding: 20rpx;
				border-bottom: 1px solid #eee;
			}

			.select-box {
				height: 400rpx;

				.select-item {
					padding: 20rpx 0 20rpx 80rpx;
					border-bottom: 1px solid #eee;
					display: flex;
				}
			}
		}
	}
</style>
